<template>
	<view class="grid-box ">
		<text class="text-bgc" v-for="(item, index) in list" :key="index" @click="add(item.id)">{{item.tag}}</text>

		<view class="foot_box"></view>
		<!-- 加载提示 -->
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<!-- 信息提示-->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				tagIdList: []
			};
		},
		onShow() {},
		onLoad(e) {
			this.getUserList()
		},
		methods: {
			async getUserList() {
				const res = await this.$u.get('api/user/sys/tag/list')
				this.list = res.data
			},
			
			async addSetTag() {
				const res = await this.$u.post('api/user/tag/saveUserTag',{
					'tagIdList':this.tagIdList,
				})
			},
			
			add(id) {
				this.tagId = id
				this.tagIdList.push(id)
				this.addSetTag()
			}
		}
	};
</script>

<style lang="scss" scoped>
	.grid-box {
		padding: 30rpx;
		display: flex;
		flex-wrap: wrap;
		align-items: center;

		.text-bgc {
			color: #1F1F1F;
			font-size: 26rpx;
			margin-right: 57rpx;
			margin-bottom: 40rpx;
			padding: 20rpx 50rpx;
			background-color: #F5F5F5;
			border-radius: 10rpx;
		}
		
		// .text-bgc:nth-child(4n+0) {
		// 	margin-right: 0rpx;
		// }
	}
</style>
